package com.qianfeng.propertygroup.dao;

import com.qianfeng.propertygroup.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/***
 *
 *   █████▒█    ██  ▄████▄   ██ ▄█▀       ██████╗ ██╗   ██╗ ██████╗
 * ▓██   ▒ ██  ▓██▒▒██▀ ▀█   ██▄█▒        ██╔══██╗██║   ██║██╔════╝
 * ▒████ ░▓██  ▒██░▒▓█    ▄ ▓███▄░        ██████╔╝██║   ██║██║  ███╗
 * ░▓█▒  ░▓▓█  ░██░▒▓▓▄ ▄██▒▓██ █▄        ██╔══██╗██║   ██║██║   ██║
 * ░▒█░   ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄       ██████╔╝╚██████╔╝╚██████╔╝
 *  ▒ ░   ░▒▓▒ ▒ ▒ ░ ░▒ ▒  ░▒ ▒▒ ▓▒       ╚═════╝  ╚═════╝  ╚═════╝
 *  ░     ░░▒░ ░ ░   ░  ▒   ░ ░▒ ▒░
 *  ░ ░    ░░░ ░ ░ ░        ░ ░░ ░
 *           ░     ░ ░      ░  
 * Created with IntelliJ IDEA.
 * User: DELL
 * Date: 2020/12/21
 * Time: 20:45
 * @author 李强
 * 接口 基本的增删改查
 */
public interface UserDao {
    /**
     * 查询所有  （在service层分页）
     * @param username 用户名
     * @param dstatus 用户状态
     * @return 所有信息
     */
    @Select(" <script>\n" +
        //    "       select u.*,h.hname from user u left join house h on u.houseid=h.hid \n" +
            "       select u.username,u.password,u.image,u.dstatus,h.hname part3 from user u left join house h on u.houseid=h.hid  \n" +
            "            <where>\n" +
            "                <if test=\"username!=null and username!=''\">\n" +
            "                   and  username like concat(\"%\",#{username},\"%\")\n" +
            "                </if>\n" +
            "                <if test=\"dstatus!=null and dstatus!='' and dstatus !='-100'\">\n" +
            "                    and dstatus =#{dstatus}\n" +
            "                </if>\n" +
            "            </where>\n" +
            "        </script>\n")
    List<User> getAllUsers(@Param("username") String username, @Param("dstatus") String dstatus);

    /**
     * 删除（dstatus从0改为1）
     * @param ids
     */
    @Update(" <script>\n" +
            "            UPDATE user set dstatus='1' WHERE id in\n" +
            "            <foreach collection=\"ids\" close=\")\" open=\"(\" separator=\",\" item=\"id\">\n" +
            "                #{id}\n" +
            "            </foreach>\n" +
            "\n" +
            "        </script>\n")
    void deleteUserByIds(@Param("ids") List<String> ids);


}
